package cn.gxa.edu_adm.servlet;

import cn.gxa.edu_adm.bean.CourseType;
import cn.gxa.edu_adm.commn.model.ResultData;
import cn.gxa.edu_adm.service.CourseTypeService;
import cn.gxa.edu_adm.service.impl.CourseTypeServiceImpl;
import cn.gxa.edu_adm.utils.StringUtils;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 查询 :  get
 *  删除 :  get
 * 新增或者修改  post
 */
@WebServlet(urlPatterns = "/courseTypeSelect")
public class CourseTypeSelectServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       //请求参数
        Integer  page= StringUtils.formatInteger(req.getParameter("page"));
        Integer  limit= StringUtils.formatInteger(req.getParameter("limit"));
        String name= StringUtils.formatString(req.getParameter("name"));
        Integer  state =StringUtils.formatInteger(req.getParameter("state"));
        //操作层
        //传入service 进行筛选查询 data
        ResultData resultData=new CourseTypeServiceImpl().findByManyWhere(page,limit,name,state);
        //响应给前端
        PrintWriter writer = resp.getWriter();
        writer.print(JSON.toJSONString(resultData));
        writer.close();
    }
}
